/*
 * @Author: long-xinyu2 2192763423@qq.com
 * @Date: 2025-04-09 18:23:34
 * @LastEditors: long-xinyu2 2192763423@qq.com
 * @LastEditTime: 2025-05-08 19:17:27
 * @FilePath: \algorithm\algorithm-training\duipai\judge.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<bits/stdc++.h>
using namespace std;
void f(int sx,int sy,int k,int x,int y);
vector<vector<int> > a;
int main() {    
    cout << "请输入棋盘大小" << endl;
    cout << "请输入棋子坐标x,y" << endl;
    int k,x,y,ss;
    cin >> k >> x >> y;
    ss=(1<<k)+5;
    for(int i=0;i<ss;i++) {
        vector<int> d;
        for(int j=0;j<ss;j++) d.push_back(0);
        a.push_back(d);
    }
    f(0,0,k,x-1,y-1);
    for(int i=0;i<(1<<k);i++) {
        for(int j=0;j<(1<<k);j++)
            printf("%d ",a[i][j]);
        printf("\n");
    }
}
void f(int sx,int sy,int k,int x,int y) {
    if(k==0) return;
    int s,m=1ll<<(k-1);
    s=x/m*2+y/m+1;
    x%=m; y%=m;
    if(s==1) {      
        f(sx,sy,k-1,x,y); 
        f(sx,sy+m,k-1,m-1,0); a[sx+m-1][sy+m]=4;
        f(sx+m,sy,k-1,0,m-1); a[sx+m][sy+m-1]=4;
        f(sx+m,sy+m,k-1,0,0); a[sx+m][sy+m]=4;
    }
    if(s==2) { 
        f(sx,sy,k-1,m-1,m-1); a[sx+m-1][sy+m-1]=3;
        f(sx,sy+m,k-1,x,y);
        f(sx+m,sy,k-1,0,m-1); a[sx+m][sy+m-1]=3;
        f(sx+m,sy+m,k-1,0,0); a[sx+m][sy+m]=3;
    }
    if(s==3) {
        f(sx,sy,k-1,m-1,m-1); a[sx+m-1][sy+m-1]=2;
        f(sx,sy+m,k-1,m-1,0); a[sx+m-1][sy+m]=2;
        f(sx+m,sy,k-1,x,y); 
        f(sx+m,sy+m,k-1,0,0); a[sx+m][sy+m]=2;
    }
    if(s==4) {
        f(sx,sy,k-1,m-1,m-1); a[sx+m-1][sy+m-1]=1;
        f(sx,sy+m,k-1,m-1,0); a[sx+m-1][sy+m]=1;
        f(sx+m,sy,k-1,0,m-1); a[sx+m][sy+m-1]=1;
        f(sx+m,sy+m,k-1,x,y); 
    }
}